
import { unreadNum } from '@/api/socket'
import store from '@/store'

const state = {
	countsTips: 0
}

const mutations = {
	SET_COUNT(state, count) {
		state.countsTips = Number(count)
	}
}

const actions = {
	// 获取提醒条数
	getCounts({ commit, state }) {
		const obj = {
			channelId: 'ItApp-ProductInfo-Management',
			msgType: '1',
			orderBy: 'create_date desc',
			roleId: '1',
			userId: store.getters.name
		}
		unreadNum(obj).then(res => {
			if (res.status === 200) {
				if (res && res.data) {
					commit('SET_COUNT', res.data.counts)
				}
			}
		})
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
